package FreebaseMatchWiki;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.*;
import raphaelMatcher.*;
public class SplitSentences {

	/**
	 * @param args
	 */

	public static void main1(String[] args) throws Exception {
		String dirStype = args[0];
		for (int i = 1; i <= 5; i++) {
			File f = new File(dirStype.replace("@", "0"+i));
			if(!f.exists()){
				f.mkdir();
			}
		}
	}
	static int NODES = 10;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		String sen_file = args[0];
//		BufferedReader br = new BufferedReader(new InputStreamReader(
//				new FileInputStream(sen_file),"utf-8"));
		DelimitedReader dr = new DelimitedReader(sen_file);
		
		DelimitedWriter []dw = new DelimitedWriter[NODES];
		for(int i=0;i<10;i++){
			String file = args[1].replace("@", "0"+(i/2+1))+"\\wikisen."+i;
		    dw[i] = new DelimitedWriter(file);
		}
		int ln=0;
		do{
			ln++;
			if(ln%10000==0)System.out.print(".");
			if(ln%1000000 == 0)System.out.println((new java.util.Date()).toString());
			try{
				String[]abc = dr.read();
				int id = ln%10;
				dw[id].write(abc[CreateSentencesSchema.cs_articleId]+abc[CreateSentencesSchema.cs_sentenceId]+abc[CreateSentencesSchema.cs_sentence]);
				if(abc == null)break;
			}catch(Exception e){
				System.err.println("Error in Line:  "+ln);
			}
		}while(true);
		dr.close();
		for(DelimitedWriter dwi : dw)dwi.close();
	}
	
	

}
